package com.ljx.common.core;

import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * @类名: Result
 * @描述:
 * @日期: 2020-09-07 16:05
 * @作者: 刘纪譞
 * @版本: 1.0.0
 * <p>
 * since JDK 1.8
 **/

@Data
@AllArgsConstructor
public class Result<T> {
    static String SUCCESS_CODE = "0000";
    static String ERROR_CODE = "1111";
    private String code;
    private T data;
    private String msg = "ok";

    private Result() {
    }

    public static Result success() {

        return new Result<>(SUCCESS_CODE, true, "ok");
    }
    public static <T> Result success(T t) {
        return new Result<>(SUCCESS_CODE, t, "ok");
    }
    public static <T> Result success(String msg) {
        return new Result<>(SUCCESS_CODE, true, msg);
    }
    public static Result fail() {
        return new Result<>(ERROR_CODE,false, "系统错误");
    }
    public static Result fail(String message) {
        return new Result<>(ERROR_CODE,false, message);
    }
    public static Result fail(String error,String message) {
        return new Result<>(error,false, message);
    }
}
